/*
 * Copyright (c) 2016, www.zm0618.com All Rights Reserved..
 */

package com.ibetter.mr.grade.medic.tag;

import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.io.FloatWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * Created by zhaojun on 2016/12/15.
 */
public class GradeUserTagScoreMergeMapper extends Mapper<LongWritable,Text,Text,FloatWritable>{
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        if (value!=null){
            String  valStr=value.toString();
            if (StringUtils.isNotBlank(StringUtils.trim(valStr))){
                String[] mergeLine = StringUtils.split(valStr, "\t");//用户ID 分类  分数
                context.write(new Text(StringUtils.join(new String[]{mergeLine[0],mergeLine[1]},"\t")),new FloatWritable(Float.parseFloat(StringUtils.trim(mergeLine[2]))));
            }
        }
    }
}
